var ArrayUtility = {
    // array: [],
    Select(data) {
        var array = [];
        let parentidArr = data.filter((item) => item.parentid == 0)
        parentidArr.forEach((item) => {
            let select_array = data.filter((ite) => ite.parentid == item.id)
            if (select_array.length >= 0) {
                array.push({
                    value: item.id,
                    label: item.title,
                    children: ArrayUtility.Select_child(select_array, data),
                })
            }
        })
        return array
    },
    Select_child(arr, data) {
        var child_arr = []
        arr.forEach((item) => {
            let a = data.filter((ite) => ite.parentid == item.id)
            child_arr.push({
                value: item.id,
                label: item.title,
                children: ArrayUtility.Select_child(a, data),
            })
        })

        return child_arr;
    },
}
var StringUtility = {
    isEnglish(str) {
        var reg = /^[A-Za-z]+$/;
        return reg.test(str);
    }
}
export default {
    ArrayUtility,
    StringUtility
}
